package com.chi.thread.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * 实现callable方法，
 * @author chi  2017-06-22 22:06
 **/
public class MyCallable implements Callable<Integer> {

    private static AtomicInteger atomicInteger= new AtomicInteger(0);

    public Integer call() throws Exception {
        return atomicInteger.incrementAndGet();
    }

    public static void main(String[] args){
        for (int i = 1; i<100; i++){
            MyCallable myCallable = new MyCallable();
            try {
                Integer call = myCallable.call();
                System.out.println(call);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
